/* 
 *
 */
package com.cory.admin.sys.controller;

import com.cory.admin.sys.config.AdminConstants;
import com.cory.admin.sys.domain.AdminPrincipal;
import com.cory.boot.base.BaseController;

/**
 * 管理台基类
 * @author xiongcong
 * @date 2020-01-21
 */
public class AdminController extends BaseController {
    
    /**
     * 获取session中的用户信息
     * @param session
     * @return
     * @author xiongcong 2019-03-04
     */
    public AdminPrincipal getPrincipal() {
        return (AdminPrincipal)request.getSession().getAttribute(AdminConstants.SESSION_USER_INFO);
    }
    
    /**
     * 获取session中的租户id
     * @param session
     * @return
     * @author xiongcong 2019-03-04
     */
    public Integer getTenantId() {
        AdminPrincipal principal = getPrincipal();
        return principal != null ? principal.getTenantId() : null;
    }
    
    /**
     * 获取session中的用户id
     * @param session
     * @return
     * @author xiongcong 2019-03-04
     */
    public Integer getUserId() {
        AdminPrincipal principal = getPrincipal();
        return principal != null ? principal.getUserId() : null;
    }
    
}
